package LoginUtil;

public class UserBean {
	
    private String username;
    private String password;
    private String firstName;
    private String lastName;
    private String type;
    public boolean valid;
	
    public UserBean()
    {	}
    
    public UserBean(String user, String pw, String fn, String ln)
    {
    	username = user;
    	password = pw;
    	firstName = fn;
    	lastName = ln;
    }
	
    public String getFirstName() {
       return firstName;
	}

    public void setFirstName(String newFirstName) {
       firstName = newFirstName;
	}

	
    public String getLastName() {
       return lastName;
			}

    public void setLastName(String newLastName) {
       lastName = newLastName;
			}
			

    public String getPassword() {
       return password;
	}

    public void setPassword(String newPassword) {
       password = newPassword;
	}
	
			
    public String getUsername() {
       return username;
			}

    public void setUserName(String newUsername) {
       username = newUsername;
			}
    
    public String getType() {
    	return type;
    }
    
    public int getTypeForDB()
    {
    	if(this.type.compareTo("admin")== 0 )
    		return 1;
    	else if(this.type.compareTo("doctor")==0)
    		return 2;
    	else if(this.type.compareTo("nurse")==0)
    		return 3;
    	else 
    		return 4;
    }

    public void setType(int type) {
    	// type is stored in DB as int, here it is converted to String
    	if(type == 1 )
    	{
    		this.type = "admin";
    	}
    	else if(type == 2 )
    	{
    		this.type = "doctor";
    	}
    	else if(type == 3 )
    	{
    		this.type = "nurse";
    	}
    	else if(type == 4 )
    	{
    		this.type = "patient";
    	}
    	else
    	{
    		this.type = "patient";
    	}
    }
				
    public boolean isValid() {
       return valid;
	}

    public void setValid(boolean newValid) {
       valid = newValid;
	}	
}

